package com.some;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class BianLiFeng_2 {
    int length;
    boolean[] flag;

    public void find(int[][] num) {
        length = num.length;
        flag = new boolean[length];
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < length; i++) {
            dfs(num, i, 0, 0, list);
        }
        int max = Integer.MAX_VALUE;
        for (Integer integer : list) {
            max = Math.min(max, integer);
        }
        System.out.println(length - 1 + " " + max);
        /*int[][] res = {{length-1,max}};
        return res;*/
    }

    public void dfs(int[][] num, int startX, int count, int sum, List<Integer> list) {
        if (count == length) {
            list.add(sum);
        }
        //该点访问过
        flag[startX] = true;
        for (int i = 0; i < num[0].length; i++) {
            if (num[startX][i] != 0 && num[startX][i] != -1 && !flag[startX]) {
                dfs(num, i, count + 1, sum + num[startX][i], list);
            }
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] distances = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                distances[i][j] = scanner.nextInt();
            }
        }
        new BianLiFeng_2().find(distances);
    }
}
